﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace Set
{
    class Program
    {
        static void Main(string[] args)
        {
            //C# 自带集合  HashSet，ISet
            //HashSet<T>集包含不重复元素的无序列表
            //SortedSet<T>集包含不重复元素的有序列表。
            //ISet<T> 接口提供的方法可以创建合集，交集，或者给出一个是另一个集的超集或子集的信息。
            //var companyTeams = new HashSet<string>() { "Ferrari", "McLaren", "Mercedes" };
            //var traditionalTeams = new HashSet<string>() { "Ferrari", "McLaren" };
            //var allTeams = new SortedSet<string>(companyTeams);
            //var companyTeams2 = new SortedSet<string>() { "Ferrari", "McLaren", "Mercedes" };


            //HashSet,SortedSet,Dictionary,IDictionary,SortedList,Hashtable,LinkedList,Stack,Queue



            //二分搜索树比链表快
            string pridePath = Directory.GetCurrentDirectory() + @"\Txt\pride-and-prejudice.txt";
            string atable = Directory.GetCurrentDirectory() + @"\Txt\a-tale-of-two-cities.txt";

            List<string> pridelist = new FileOperation(pridePath).readFile();
            List<string> atablelist = new FileOperation(atable).readFile();

            Console.WriteLine(pridelist.Count);
            Console.WriteLine(atablelist.Count);

            Console.WriteLine();

            BSTSet<string> set1 = new BSTSet<string>();
            foreach (var word in pridelist)
                set1.add(word);
            Console.WriteLine("Total different words: " + set1.getSize());


            BSTSet<string> set2 = new BSTSet<string>();
            foreach (var word in atablelist)
                set2.add(word);
            Console.WriteLine("Total different words: " + set2.getSize());

            Console.WriteLine();

            LinkedListSet<string> Linkedset1 = new LinkedListSet<string>();
            foreach (var word in pridelist)
                Linkedset1.add(word);
            Console.WriteLine("Total different words: " + Linkedset1.getSize());


            LinkedListSet<string> Linkedset2 = new LinkedListSet<string>();
            foreach (var word in atablelist)
                Linkedset2.add(word);
            Console.WriteLine("Total different words: " + Linkedset2.getSize());
        }
    }
}
